﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeHeng_Mes.Mapper
{
    public static class ErrorMappingTable
    {
        /// <summary>
        /// 故障类型名称映射表
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetTypeName(string type)
        {
            Dictionary<string,string> dic = new Dictionary<string, string>()
            {
                {"Independent1","上游PLC关联故障" },
                {"Independent2","下游PLC关联故障" },

                {"Robot","机器人状态" },
                {"Jig_L","左侧夹具故障" },
                {"Jig_R","右侧夹具故障" },
                {"Jig_L_Sen","左侧夹具传感器故障" },
                {"Jig_R_Sen","右侧夹具传感器故障" },
                {"Motor","电机故障" },
                {"SG_ST","安全门故障" },
                {"Raster_st","光栅故障" },
                {"Estop","急停" },
                {"State","通讯故障" },
                {"Device","设备报警" },

                {"Jia","压铆夹具报警" },
                {"Sensor","压铆传感器报警" },
                {"Servo","压铆伺服报警" },
                {"Secure","压铆安全报警" },
                {"Communication","压铆通讯报警" },
            };

            if(dic.TryGetValue(type, out string typeName))
            {
                return typeName;
            }
            return null;
        }

        /// <summary>
        /// 反向获取Key
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetTypeKey(string value)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>()
            {
                {"Independent1","上游PLC关联故障" },
                {"Independent2","下游PLC关联故障" },

                {"Robot","机器人状态" },
                {"Jig_L","左侧夹具故障" },
                {"Jig_R","右侧夹具故障" },
                {"Jig_L_Sen","左侧夹具传感器故障" },
                {"Jig_R_Sen","右侧夹具传感器故障" },
                {"Motor","电机故障" },
                {"SG_ST","安全门故障" },
                {"Raster_st","光栅故障" },
                {"Estop","急停" },
                {"State","通讯故障" },
                {"Device","设备报警" },

                {"Jia","压铆夹具报警" },
                {"Sensor","压铆传感器报警" },
                {"Servo","压铆伺服报警" },
                {"Secure","压铆安全报警" },
                {"Communication","压铆通讯报警" },
            };

            foreach (var item in dic)
            {
                if(item.Value.Equals(value))
                    return item.Key;
            }
            return null;
        }

        /// <summary>
        /// 获取详细信息
        /// </summary>
        /// <param name="name"></param>
        /// <param name="key"></param>
        /// <param name="i"></param>
        /// <returns></returns>
        public static string GetMessage(string plcName, string errorType, int index)
        {
            Dictionary<string, Dictionary<string, Dictionary<int, string>>> dic = new Dictionary<string, Dictionary<string, Dictionary<int, string>>>();

            dic["DOOR-02"] = new Dictionary<string, Dictionary<int, string>>()
            {
                { "Jig_L",new Dictionary<int, string>()
                {

                    { 9,"OP110LNG_夹具故障"},
                    { 10,"OP110L_夹具故障"},
                    { 11,"OP120L_夹具故障"},
                    { 12,"OP130L_夹具故障"},
                    { 13,"OP140L_夹具故障"},
                    { 14,"OP150L_夹具故障"},
                    { 15,"OP160L_夹具故障"},
                    { 16,"OP155_夹具故障"},
                    { 17,"OP180L_夹具故障"},
                } },
                { "Jig_R",new Dictionary<int, string>()
                {

                    { 9,"OP110RNG_夹具故障"},
                    { 10,"OP110R_夹具故障"},
                    { 11,"OP120R_夹具故障"},
                    { 12,"OP130R_夹具故障"},
                    { 13,"OP140R_夹具故障"},
                    { 14,"OP150R_夹具故障"},
                    { 15,"OP160R_夹具故障"},
                    { 16,"OP180R_夹具故障"},
                } },
                { "Jig_L_Sen",new Dictionary<int, string>()
                {

                    { 0,"OP10L_JIG_SEN报错"},
                    { 1,"OP20L_JIG_SEN报错"},
                    { 2,"OP30L_JIG_SEN报错"},
                    { 3,"OP40L_JIG_SEN报错"},
                    { 4,"OP50L_JIG_SEN报错"},
                    { 5,"OP50L_皮带机_SEN报错"},
                    { 10,"OP110L_JIG_SEN报错"},
                    { 11,"OP120LA_JIG_SEN报错"},
                    { 12,"OP120LB_JIG_SEN报错"},
                    { 13,"OP130L_JIG_SEN报错"},
                    { 14,"OP140L_JIG_SEN报错"},
                    { 15,"OP150L_JIG_SEN报错"},
                    { 16,"OP160L_JIG_SEN报错"},
                    { 17,"OP180L_JIG_SEN报错"},
                    { 18,"OP155_JIG_SEN报错"},
                } },
                { "Jig_R_Sen",new Dictionary<int, string>()
                {
                    { 0,"OP10R_JIG_SEN报错"},
                    { 1,"OP20R_JIG_SEN报错"},
                    { 2,"OP30R_JIG_SEN报错"},
                    { 3,"OP40R_JIG_SEN报错"},
                    { 4,"OP50R_JIG_SEN报错"},
                    { 5,"OP50R_皮带机_SEN报错"},
                    { 10,"OP110R_JIG_SEN报错"},
                    { 11,"OP120RA_JIG_SEN报错"},
                    { 12,"OP120RB_JIG_SEN报错"},
                    { 13,"OP130R_JIG_SEN报错"},
                    { 14,"OP140R_JIG_SEN报错"},
                    { 15,"OP150R_JIG_SEN报错"},
                    { 16,"OP160R_JIG_SEN报错"},
                    { 17,"OP180R_JIG_SEN报错"},
                } },
                { "Motor",new Dictionary<int, string>()
                {
                    { 0,"皮带机L电机报错"},
                    { 1,"皮带机R电机报错"},
                    { 2,"120L电机报错"},
                    { 3,"120R电机报错"},
                } },
                { "SG_ST",new Dictionary<int, string>()
                {
                    { 0,"SD1安全门打开"},
                    { 1,"SD2安全门打开"},
                    { 2,"SD3安全门打开"},
                    { 3,"SD4安全门打开"},
                    { 4,"SD5安全门打开"},
                    { 5,"SD6安全门打开"},
                } },
                { "Raster_st",new Dictionary<int, string>()
                {
                    { 8,"OP140区域隔离光栅被闯入"},
                } },
                { "Estop",new Dictionary<int, string>()
                {
                    { 0,"HMI1急停"},
                    { 1,"HMI2急停"},
                    { 2,"HMI3急停"},
                    { 3,"HMI4急停"},
                    { 4,"HMI5急停"},
                    { 5,"HMI6急停"},
                    { 6,"HMI7急停"},
                    { 7,"HMI8急停"},
                    { 8,"HMI9急停"},
                    { 9,"HMI10急停"},
                    { 10,"OP110L-OB急停"},
                    { 11,"OP110R-OB急停"},
                    { 12,"OP120L-OB急停"},
                    { 13,"OP120R-OB急停"},
                    { 14,"OP130L-OB急停"},
                    { 15,"OP130R-OB急停"},
                    { 16,"OP140L-OB急停"},
                    { 17,"OP140R-OB急停"},
                    { 18,"OP155-OB1急停"},
                    { 19,"OP160L-OB急停"},
                    { 20,"OP160R-OB急停"},
                    { 21,"OP180L-OB急停"},
                    { 22,"OP180R-OB急停"},
                    { 23,"SD1-急停"},
                    { 24,"SD2-急停"},
                    { 25,"SD3-急停"},
                    { 26,"SD4-急停"},
                    { 27,"R9急停"},
                    { 28,"R10急停"},
                    { 29,"R11急停"},
                    { 30,"R12急停"},
                    { 31,"R13急停"},
                    { 32,"R14急停"},
                    { 33,"R15急停"},
                    { 34,"R16急停"},
                    { 35,"R17急停"},
                    { 36,"R18急停"},
                    { 37,"R19急停"},
                    { 38,"R20急停"},
                    { 39,"R21急停"},
                    { 40,"R22急停"},
                    { 41,"R23急停"},
                    { 42,"R24急停"},
                    { 43,"R25急停"},
                } },
                { "State",new Dictionary<int, string>()
                {
                    { 0,"CPU通讯故障"},
                    { 19,"耦合器通讯故障"},
                    { 24,"HMI3_ET200通讯故障"},
                    { 25,"HMI4_ET200通讯故障"},
                    { 26,"HMI7_ET200通讯故障"},
                    { 27,"HMI8_ET200通讯故障"},
                    { 28,"OP120LA_ET200通讯故障"},
                    { 29,"OP120LB_ET200通讯故障"},
                    { 30,"OP130L_ET200通讯故障"},
                    { 31,"OP130R_ET200通讯故障"},
                    { 32,"OP140L_ET200通讯故障"},
                    { 33,"OP140R_ET200通讯故障"},
                    { 34,"OP150L_ET200通讯故障"},
                    { 35,"OP150R_ET200通讯故障"},
                    { 36,"OP120RA_ET200通讯故障"},
                    { 37,"OP120RB_ET200通讯故障"},
                    { 38,"MCP_ET200通讯故障"},
                    { 39,"OP120VD_ET200通讯故障"},
                    { 40,"OP110L_BK01通讯故障"},
                    { 41,"OP110L_BK02通讯故障"},
                    { 42,"OP110R_BK01通讯故障"},
                    { 43,"OP110R_BK02通讯故障"},
                    { 44,"OP110LNG_BK01通讯故障"},
                    { 45,"OP110RNG_BK01通讯故障"},
                    { 47,"OP120L_BK02通讯故障"},
                    { 48,"OP120R_BK02通讯故障"},
                    { 50,"OP130L_BK01通讯故障"},
                    { 51,"OP130L_BK02通讯故障"},
                    { 52,"OP130R_BK01通讯故障"},
                    { 53,"OP130R_BK02通讯故障"},
                    { 54,"OP140L_BK01通讯故障"},
                    { 55,"OP140L_BK02通讯故障"},
                    { 56,"OP140R_BK01通讯故障"},
                    { 57,"OP140R_BK02通讯故障"},
                    { 58,"OP150L_BK01通讯故障"},
                    { 59,"OP150L_BK02通讯故障"},
                    { 60,"OP150R_BK01通讯故障"},
                    { 61,"OP150R_BK02通讯故障"},
                    { 62,"OP160L_BK01通讯故障"},
                    { 63,"OP160R_BK01通讯故障"},
                    { 64,"OP180R_BK01通讯故障"},
                    { 65,"OP180R_BK02通讯故障"},
                    { 66,"OP155_BK01通讯故障"},
                    { 87,"OP120L-VFD通讯故障"},
                    { 88,"OP120R-VFD通讯故障"},
                    { 94,"OP0120RA_PM01通讯故障"},
                    { 95,"OP0120RB_PM01通讯故障"},
                    { 96,"HMI5_ET200通讯故障"},
                    { 97,"HMI6_ET200通讯故障"},
                    { 99,"OP0110L_PM01通讯故障"},
                    { 100,"OP0110R_PM01通讯故障"},
                    { 101,"OP0110LNG_PM01通讯故障"},
                    { 102,"OP0110RNG_PM01通讯故障"},
                    { 103,"OP0120LA_PM01通讯故障"},
                    { 104,"OP0120LB_PM01通讯故障"},
                    { 105,"OP0130L_PM01通讯故障"},
                    { 106,"OP0130R_PM01通讯故障"},
                    { 107,"OP0140L_PM01通讯故障"},
                    { 108,"OP0140R_PM01通讯故障"},
                    { 109,"OP0150L_PM01通讯故障"},
                    { 110,"OP0150R_PM01通讯故障"},
                    { 111,"OP0160L_PM01通讯故障"},
                    { 112,"OP0160R_PM01通讯故障"},
                    { 113,"OP0180L_PM01通讯故障"},
                    { 114,"OP0180R_PM01通讯故障"},
                    { 115,"OP0155_PM01通讯故障"},
                    { 116,"120L拉铆枪通讯故障"},
                    { 118,"120R拉铆枪通讯故障"},
                    { 120,"R9通讯故障"},
                    { 121,"R10通讯故障"},
                    { 122,"R11通讯故障"},
                    { 123,"R12通讯故障"},
                    { 124,"R13通讯故障"},
                    { 125,"R14通讯故障"},
                    { 126,"R15通讯故障"},
                    { 127,"R16通讯故障"},
                    { 128,"R17通讯故障"},
                    { 129,"R18通讯故障"},
                    { 130,"R19通讯故障"},
                    { 131,"R20通讯故障"},
                    { 132,"R21通讯故障"},
                    { 133,"R22通讯故障"},
                    { 134,"R23通讯故障"},
                    { 135,"R24通讯故障"},
                    { 136,"R25通讯故障"},
                    { 139,"R9/R10SCA通讯故障"},
                    { 159,"OP160L拧紧枪1-通讯故障"},
                    { 160,"OP160L拧紧枪2-通讯故障"},
                    { 161,"OP160R拧紧枪1-通讯故障"},
                    { 162,"OP160R拧紧枪2-通讯故障"},
                } },
                { "Device",new Dictionary<int, string>()
                {
                    { 0,"R11缺钉"},
                    { 1,"R12缺钉"},
                    { 2,"R14缺钉"},
                    { 3,"R15缺钉"},
                    { 4,"R17缺钉"},
                    { 5,"R18缺钉"},
                    { 6,"R20缺钉"},
                    { 7,"R21缺钉"},
                    { 8,"冷却机故障"},
                    { 9,"R9胶机故障"},
                    { 10,"R10胶机故障"},
                    { 11,"R22胶机故障"},
                } },
            };




            dic["DOOR-01"] = new Dictionary<string, Dictionary<int, string>>()
            {
                { "Jig_L",new Dictionary<int, string>()
                {

                    { 0,"OP10L_夹具故障"},
                    { 1,"OP20L_夹具故障"},
                    { 2,"OP30L_夹具故障"},
                    { 3,"OP40L_夹具故障"},
                    { 4,"OP50L_夹具故障"},
                    { 5,"OP60L_夹具故障"},
                    { 6,"OP70L_夹具故障"},
                    { 7,"OP80L_夹具故障"},
                    { 8,"OP90L_夹具故障"},
                    { 9,"OP100L_夹具故障"},
                } },
                { "Jig_R",new Dictionary<int, string>()
                {

                    { 0,"OP10L_夹具故障"},
                    { 1,"OP20L_夹具故障"},
                    { 2,"OP30L_夹具故障"},
                    { 3,"OP40L_夹具故障"},
                    { 4,"OP50L_夹具故障"},
                    { 5,"OP60L_夹具故障"},
                    { 6,"OP70L_夹具故障"},
                    { 7,"OP80L_夹具故障"},
                    { 8,"OP90L_夹具故障"},
                    { 9,"OP100L_夹具故障"},
                } },
                { "Jig_L_Sen",new Dictionary<int, string>()
                {

                    { 0,"OP10L_夹具传感器故障"},
                    { 1,"OP20L_夹具传感器故障"},
                    { 2,"OP30L_夹具传感器故障"},
                    { 3,"OP40L_夹具传感器故障"},
                    { 4,"OP50L_夹具传感器故障"},
                    { 5,"OP60L_夹具传感器故障"},
                    { 10,"OP70L_夹具传感器故障"},
                    { 11,"OP80L_夹具传感器故障"},
                    { 12,"OP90L_夹具传感器故障"},
                    { 13,"OP100L_夹具传感器故障"},
                } },
                { "Jig_R_Sen",new Dictionary<int, string>()
                {
                    { 0,"OP10R_夹具传感器故障"},
                    { 1,"OP20R_夹具传感器故障"},
                    { 2,"OP30R_夹具传感器故障"},
                    { 3,"OP40R_夹具传感器故障"},
                    { 4,"OP50R_夹具传感器故障"},
                    { 5,"OP60R_夹具传感器故障"},
                    { 10,"OP70R_夹具传感器故障"},
                    { 11,"OP80R_夹具传感器故障"},
                    { 12,"OP90R_夹具传感器故障"},
                    { 13,"OP100R_夹具传感器故障"},
                } },
                { "Motor",new Dictionary<int, string>()
                {
                    { 0,"OP90左侧翻台报警"},
                    { 1,"OP90右侧翻台报警"},
                } },
                { "SG_ST",new Dictionary<int, string>()
                {
                    { 0,"SD1安全门打开"},
                    { 1,"SD2安全门打开"},
                    { 2,"SD3安全门打开"},
                    { 3,"SD4安全门打开"},
                    { 4,"SD5安全门打开"},
                    { 5,"SD6安全门打开"},
                    { 6,"SD7安全门打开"},
                    { 7,"SD8安全门打开"},
                    { 8,"SD9安全门打开"},
                    { 9,"SD10安全门打开"},
                } },
                { "Raster_st",new Dictionary<int, string>()
                {
                    { 6,"PLC1和PLC2隔离光栅被闯入"},
                } },
                { "Estop",new Dictionary<int, string>()
                {
                    { 0,"HMI1急停"},
                    { 1,"HMI2急停"},
                    { 2,"HMI3急停"},
                    { 3,"HMI4急停"},
                    { 10,"OP20L-OB1急停"},
                    { 11,"OP20L-OB2急停"},
                    { 12,"OP20R-OB3急停"},
                    { 13,"OP20R-OB4急停"},
                    { 14,"OP20R-OB5急停"},
                    { 15,"OP30L-OB1急停"},
                    { 16,"OP30R-OB2急停"},
                    { 17,"OP40L-OB1急停"},
                    { 18,"OP40L-OB2急停"},
                    { 19,"OP40R-OB3急停"},
                    { 20,"OP40R-OB4急停"},
                    { 21,"OP50L-OB急停"},
                    { 22,"OP50R-OB急停"},
                    { 23,"OP60L-OB急停"},
                    { 24,"OP60R-OB急停"},
                    { 25,"OP70L-OB急停"},
                    { 26,"OP70R-OB急停"},
                    { 27,"OP80L-OB急停"},
                    { 28,"OP80R-OB急停"},
                    { 29,"OP90L-OB急停"},
                    { 30,"OP90R-OB急停"},
                    { 31,"OP100L-OB急停"},
                    { 32,"OP100R-OB急停"},
                    { 40,"SD1急停"},
                    { 41,"SD2急停"},
                    { 42,"SD3急停"},
                    { 50,"R1急停"},
                    { 51,"R2急停"},
                    { 52,"R3急停"},
                    { 53,"R4急停"},
                    { 54,"R5急停"},
                    { 55,"R6急停"},
                    { 56,"R7急停"},
                    { 57,"R8急停"},
                } },
                { "State",new Dictionary<int, string>()
                {
                    { 10,"HMI3-ET200通讯故障"},
                    { 11,"HMI4-ET200通讯故障"},
                    { 17,"OP100L_ET200通讯故障"},
                    { 18,"OP100R_ET200通讯故障"},
                    { 19,"耦合器通讯故障"},
                    { 24,"OP20L_ET200通讯故障"},
                    { 25,"OP20R_ET200通讯故障"},
                    { 26,"OP30L_ET200通讯故障"},
                    { 27,"OP30R_ET200通讯故障"},
                    { 28,"OP40L_ET200通讯故障"},
                    { 29,"OP40R_ET200通讯故障"},
                    { 30,"OP50L_ET200通讯故障"},
                    { 31,"OP50R_ET200通讯故障"},
                    { 32,"OP70L_ET200通讯故障"},
                    { 33,"OP70R_ET200通讯故障"},
                    { 34,"OP90L_ET200通讯故障"},
                    { 35,"OP90R_ET200通讯故障"},
                    { 36,"OP100L_ET200通讯故障"},
                    { 37,"OP100R_ET200通讯故障"},
                    { 38,"MCP-ET200通讯故障"},
                    { 39,"J1-ET200通讯故障"},
                    { 40,"60L-BK01通讯故障"},
                    { 41,"60R-BK02通讯故障"},
                    { 42,"70L-BK01通讯故障"},
                    { 43,"70L-BK02通讯故障"},
                    { 44,"70R-BK01通讯故障"},
                    { 45,"70R-BK02通讯故障"},
                    { 46,"80L-BK01通讯故障"},
                    { 47,"80R-BK02通讯故障"},
                    { 49,"20L拉铆枪2通讯故障"},
                    { 51,"20R拉铆枪2通讯故障"},
                    { 53,"20L拉铆枪1通讯故障"},
                    { 55,"20R拉铆枪3通讯故障"},
                    { 57,"30L拉铆枪通讯故障"},
                    { 59,"20R拉铆枪1通讯故障"},
                    { 61,"40L拉铆枪1通讯故障"},
                    { 63,"40L拉铆枪2通讯故障"},
                    { 65,"30R拉铆枪通讯故障"},
                    { 67,"40R拉铆枪1通讯故障"},
                    { 69,"40R拉铆枪2通讯故障"},
                    { 71,"50L拉铆枪1通讯故障"},
                    { 73,"50L拉铆枪2通讯故障"},
                    { 75,"50L拉铆枪3通讯故障"},
                    { 77,"50R拉铆枪1通讯故障"},
                    { 79,"50R拉铆枪2通讯故障"},
                    { 81,"50R拉铆枪3通讯故障"},
                    { 83,"100L拉铆枪2通讯故障"},
                    { 85,"100L拉铆枪1通讯故障"},
                    { 87,"100R拉铆枪1通讯故障"},
                    { 89,"100R拉铆枪2通讯故障"},
                    { 91,"20L拉铆枪3通讯故障"},
                    { 93,"20R拉铆枪4通讯故障"},
                    { 97,"APC-L-PM通讯故障"},
                    { 98,"APC-R-PM通讯故障"},
                    { 99,"20-L-PM通讯故障"},
                    { 100,"20-R-PM通讯故障"},
                    { 101,"30-L-PM通讯故障"},
                    { 102,"30-R-PM通讯故障"},
                    { 103,"40-L-PM通讯故障"},
                    { 104,"40-R-PM通讯故障"},
                    { 105,"50-L-PM通讯故障"},
                    { 106,"50-R-PM通讯故障"},
                    { 107,"60-L-PM通讯故障"},
                    { 108,"60-R-PM通讯故障"},
                    { 109,"70-L-PM1通讯故障"},
                    { 110,"70-R-PM1通讯故障"},
                    { 111,"80-L-PM通讯故障"},
                    { 112,"80-R-PM通讯故障"},
                    { 113,"90-L-PM通讯故障"},
                    { 114,"90-R-PM通讯故障"},
                    { 115,"100-L-PM通讯故障"},
                    { 116,"100-R-PM通讯故障"},
                    { 117,"70-L-PM2通讯故障"},
                    { 118,"70-R-PM2通讯故障"},
                    { 120,"R1通讯故障"},
                    { 121,"R2通讯故障"},
                    { 122,"R3通讯故障"},
                    { 123,"R4通讯故障"},
                    { 124,"R5通讯故障"},
                    { 125,"R6通讯故障"},
                    { 126,"R7通讯故障"},
                    { 127,"R8通讯故障"},
                    { 134,"OP90L1-拧紧枪通讯故障"},
                    { 135,"OP90L2-拧紧枪通讯故障"},
                    { 136,"OP90R1-拧紧枪通讯故障"},
                    { 137,"OP90R2-拧紧枪通讯故障"},
                    { 141,"R5/R6SCA通讯故障"},
                    { 180,"VFD-ET200通讯故障"},
                    { 184,"OP90L-VFD通讯故障"},
                    { 185,"OP90R-VFD通讯故障"},
                } },
                { "Device",new Dictionary<int, string>()
                {
                    { 0,"APC-L 电机温度过高报警"},
                    { 1,"APC-L 链条断开报警"},
                    { 2,"APC-L 电机错位报警"},
                    { 3,"APC-R 电机温度过高报警"},
                    { 4,"APC-R 链条断开报警"},
                    { 5,"APC-R 电机错位报警"},
                    { 6,"R3缺钉"},
                    { 7,"R4缺钉"},
                    { 8,"R1 胶机故障"},
                    { 9,"R2 胶机故障"},
                    { 10,"R3 胶机故障"},
                    { 11,"R4 胶机故障"},
                } },
            };

            dic["DOOR-03"] = new Dictionary<string, Dictionary<int, string>>()
            {
                { "Jia",new Dictionary<int, string>()
                {
                    { 0,"压缸未回到原点"},
                    { 1,"模架固定缸未压紧到位"},
                    { 2,"模架固定缸未松开到位"},
                    { 3,"前插销未伸出到位"},
                    { 4,"前插销未缩回到位"},
                    { 5,"后插销未伸出到位"},
                    { 6,"后插销未缩回到位"},
                    { 7,"旋压缸未松开到位"},
                    { 8,"滑台升降缸未上升到位"},
                    { 9,"钳体第一段未缩回到位（下气缸伸出，上气缸缩回）"},
                    { 10,"钳体未伸出到位（上下气缸均伸出）"},
                    { 11,"钳体未缩回到位（上下钳体均缩回）"},
                    { 12,"钳体上顶升未缩回到位"},
                    { 13,"送料移载未伸出到位"},
                    { 14,"送料移载未缩回到位"},
                    { 15,"送料切料未伸出到位"},
                    { 16,"送料切料未缩回到位"},
                    { 17,"震动盘切料气缸长时间未伸出到位"},
                    { 18,"震动盘切料气缸长时间未缩回到位"},
                } },
                { "Sensor",new Dictionary<int, string>()
                {
                    { 0,"准备自动运行时请拔出滑台插销"},
                    { 1,"未检测到工件或工件未放好"},
                    { 2,"吹螺母后未检测到螺母到上模"},
                    { 3,"切料后未检测到螺母下落到位"},
                    { 4,"未检测到产品或产品未放好"},
                    { 5,"料道螺母低于下限，请放置螺母"},
                } },
                { "Device",new Dictionary<int, string>()
                {
                    { 0,"压缸长时间压力未到达"},
                    { 1,"压铆曲线判定NG"},
                    { 2,"扫码NG"},
                    { 3,"模具使用次数上限"},
                    { 4,"相机检测到工件已铆接螺母"},
                    { 5,"此次压装仪表判定NG"},
                } },
                { "Servo",new Dictionary<int, string>()
                {
                    { 0,"AXIS1原点丢失"},
                    { 1,"AXIS1异常"},
                } },
                { "Secure",new Dictionary<int, string>()
                {
                    { 0,"安全门被打开"},
                    { 1,"急停安全继电器断开"},
                    { 2,"自动运行时遮挡光栅"},
                } },
                { "Communication",new Dictionary<int, string>()
                {
                    { 0,"上位机通讯失败"},
                } },
            };

            dic["DOOR-04"] = new Dictionary<string, Dictionary<int, string>>()
            {
                { "Jia",new Dictionary<int, string>()
                {
                    { 0,"压缸未回到原点"},
                    { 1,"模架固定缸未压紧到位"},
                    { 2,"模架固定缸未松开到位"},
                    { 3,"前插销未伸出到位"},
                    { 4,"前插销未缩回到位"},
                    { 5,"后插销未伸出到位"},
                    { 6,"后插销未缩回到位"},
                    { 7,"旋压缸未松开到位"},
                    { 8,"滑台升降缸未上升到位"},
                    { 9,"钳体第一段未缩回到位（下气缸伸出，上气缸缩回）"},
                    { 10,"钳体未伸出到位（上下气缸均伸出）"},
                    { 11,"钳体未缩回到位（上下钳体均缩回）"},
                    { 12,"钳体上顶升未缩回到位"},
                    { 13,"送料移载未伸出到位"},
                    { 14,"送料移载未缩回到位"},
                    { 15,"送料切料未伸出到位"},
                    { 16,"送料切料未缩回到位"},
                    { 17,"震动盘切料气缸长时间未伸出到位"},
                    { 18,"震动盘切料气缸长时间未缩回到位"},
                } },
                { "Sensor",new Dictionary<int, string>()
                {
                    { 0,"准备自动运行时请拔出滑台插销"},
                    { 1,"未检测到工件或工件未放好"},
                    { 2,"吹螺母后未检测到螺母到上模"},
                    { 3,"切料后未检测到螺母下落到位"},
                    { 4,"未检测到产品或产品未放好"},
                    { 5,"料道螺母低于下限，请放置螺母"},
                } },
                { "Device",new Dictionary<int, string>()
                {
                    { 0,"压缸长时间压力未到达"},
                    { 1,"压铆曲线判定NG"},
                    { 2,"扫码NG"},
                    { 3,"模具使用次数上限"},
                    { 4,"相机检测到工件已铆接螺母"},
                    { 5,"此次压装仪表判定NG"},
                } },
                { "Servo",new Dictionary<int, string>()
                {
                    { 0,"AXIS1原点丢失"},
                    { 1,"AXIS1异常"},
                } },
                { "Secure",new Dictionary<int, string>()
                {
                    { 0,"安全门被打开"},
                    { 1,"急停安全继电器断开"},
                    { 2,"自动运行时遮挡光栅"},
                } },
                { "Communication",new Dictionary<int, string>()
                {
                    { 0,"上位机通讯失败"},
                } },
            };

            if (dic.TryGetValue(plcName,out Dictionary<string,Dictionary<int, string>> value))
            {
                if(value.TryGetValue(errorType, out Dictionary<int, string> errorValue))
                {
                    if (errorValue.TryGetValue(index, out string errorMessage))
                        return errorMessage;
                }
            }

            return null;
        }
    }
}
